define(['app','pagination','datetime','js/directive/listTree','js/filter/tree2Arr'], function( appCRM ) {
'use strict';
/*后台员工管理*/
appCRM.controller('Employee', function ($scope, $http, dataFactoryCRM , $q, $timeout) {
    $scope.search_param = {status:-2,sector:-1,ename:'',eyggh:'',estatus:-1,sex:-1,exl:-1,eduContent:'',ezzmm:-1,};
    $scope.editData = {user_id:0};
    $scope.userRoleSector = {user_id:0};
    $scope.pagerdata = { pageAll:1, pageNow:1, pageSize:$scope.psize, k: 3922 };
    $scope.users = {};
    $scope.lastUserId = $scope.user.user_id;
    $("#check_all").click(function(){
        $("input[class='check_list']").prop('checked', $(this).prop("checked"));
    });
    /*系统错误调用*/
    $scope.msgAttention = function() {
        $('.ui.systemerror').modal({
            closable: true,
            onDeny: function() {
                return true;
            },
            onApprove: function() {
                $('.ui.dimmer.modals.page.transition.visible.active.dimmers').removeClass('dimmers');
            }
        }).modal('show');

        setTimeout(function() {
            var system = $('.ui.dimmer.modals.page.transition.visible.active');
            if (system) {
                $('.ui.dimmer.modals.page.transition.visible.active').addClass('dimmers');
            }
        }, 1000);
    };

    //分页
    $scope.pagerdata = {pageAll: 1,pageNow: 1, pageSize:$scope.psize,k: 3};
    $scope.user;
    //获取分页数据
    $scope.getPageData = function(){
        var sUrl = "employee/index";
        var _param =  $scope.search_param;
        _param['psize'] = $scope.pagerdata.pageSize;
        _param['p'] = $scope.pagerdata.pageNow;
        sUrl += "?"+$.param( _param ) ;
        dataFactoryCRM.getDataByAPI( sUrl ).then( function( _d ){
            $scope.users = _d.data;
            $scope.pagerdata.pageSize = _d.psize;
            $scope.pagerdata.pageAll = _d.pall;
            $scope.pagerdata.pageNow = _d.p;

        });


    }
    $scope.getPageData();

    //加载部门
    $scope.busy = dataFactoryCRM.getDataByAPI('employee/getPageParam')
        .then( function( data ) {
            $scope.busy = false;
            if( data ) {
                $scope.sectors = data.sector;
                $scope.roles = data.role;
            }
        });

    //用户搜索
    $scope.search = function(){
        $scope.getPageData();
    }

    $scope.operation = function(key){
        //分页20条内容，后五条dropdown向上显示
        if(key%20 > 14){
            $('#menu' + key).dropdown({direction: 'upward'});
        }else{
            $('#menu' + key).dropdown();
        }
    }

    //重置密码框
    $scope.resetPass = function( user_id ){
        function _resetPass(){
            $scope.$emit("BUSY");
            dataFactoryCRM.postDataByAPI( "employee/resetPass", $scope.resetData['user'] )
                .then( function( _d ){
                    $scope.$emit("NOTBUSY");
                    if ( _d&&_d.rcode) {
                        $scope.api_success("用户密码更新成功");
                        return true;
                    }else{
                        $scope.api_error("用户密码更新失败");
                        return false;
                    }
                });
        }
        $('#pwd_reset').form('clear');
        dataFactoryCRM.getDataByAPI('employee/saveEdit?user_id='+user_id )
                .then(function(d){
                if (d&&d.rcode) {
                        $timeout(function(){
                            $scope.resetData = d.data;
                        });
                     // $('.ui.reset_confirm.modal').modal({
                     //    onApprove:function(){
                            $('.ui.reset_pass.modal').modal({
                                onApprove:function(){
                                    if ($('#pwd_reset').form('is valid')){
                                        _resetPass();
                                    }
                                    else
                                        return false;
                                }
                            }).modal('setting', 'closable', false).modal('show');
                            // return false;
                    //     }
                    // }) .modal('show');
                }
                else{
                    $scope.api_error( d.msg );
                }
            },
            function(){
                $scope.api_error('接口请求失败');
            }
        );
    }

    //退回修改
    $scope.returnEdit = function(uid) {
        dataFactoryCRM.getDataByAPI('Employee/returnEdit?user_id='+uid)
            .then(function(_d){
                if( _d.rcode ){
                    $scope.api_success(_d['msg']);
                    return true;
                }else{
                    $scope.api_error(_d['msg']);
                    return false;
                }
            });
    }

    $scope.api_error = function ( msg ) {
        $('.modal.modal2').remove();
        $('<div class="ui small modal modal2" style="text-align: center;"><div class="header">提示</div><div class="content"><i class="huge red warning outline icon"></i>' +
            '<p style="padding-top: 15px;">'+msg+'</p>' +'</div></div>'
        ).modal('show');
    };

    $scope.api_success = function( msg ){
        $('.modal.modal1').remove();
        $('<div class="ui small modal modal1" style="text-align: center;"><div class="header">提示</div><div class="content"><i class="huge green check circle outline icon"></i>' +
                '<p style="padding-top: 15px;">'+msg+'</p>' +'</div></div>'
            ).modal('show');
    };


    //添加新用户
    $scope.addUser = function( _d ){
        function _addUser( user ){
            $scope.$emit("BUSY");
            $scope.busy = dataFactoryCRM.postDataByAPI('employee/addUser', user )
            .then(function(d){
                $scope.$emit('NOTBUSY');

                if (d.rcode) {
                    $scope.userData = d.data['user'];
                    $scope.msg = '已成功在系统中添加该员工！<br>快去通知 '+ $scope.extData['ext_name'] +' 登录系统完善档案，登录名：'+ $scope.userData.login_name +' 登录密码：'+ $scope.addData['pwd'];
                    if(d.sen){
                         $scope.msg = $scope.msg +'<br>已发成功发送短信！';
                    }else{
                         $scope.msg = $scope.msg +'<br><font style="color:red;">发送短信失败！<font>';
                    }
                    
                    $scope.api_success($scope.msg);
                    $scope.getPageData();//重新加载列表
                    return true;
                }else{
                    $scope.api_error( d.msg );
                    return false;
                }
            });
        }
        $scope.addData = {login_name:'',sector_id:0,role_id:0,phone:'',weixin:'',pwd:''};
        $scope.extData = {ext_yggh:0,ext_name:'',ext_lastPer:$scope.lastUserId};
        $scope.allData = {
            data : $scope.addData,
            ext : $scope.extData
        };
        $timeout(function(){
            $('#addfrm').form('clear');
            $('.ui.dropdown.add_state').dropdown('set selected', '0');
            $scope.addData.state = 2;
            $scope.addData.login_name = '系统将自动生成';
            $scope.extData.ext_yggh = '系统将自动生成';
            $scope.addData.pwd = 'hzhfzx';
       });
        $('.ui.add').modal({
            onApprove: function() {
                if( $('#addfrm').form('is valid') ){
                    return _addUser( $scope.allData);
                }
                else
                    return false;
            }}).modal('setting', 'closable', false).modal('show');
    }



    $scope.$watch('search_param.status', function(){
            $scope.pagerdata.pageNow = 1;
            $scope.search();
        });

        $scope.sexType = [{k:'0',v:'未知'},{k:'1',v:'男'},{k:'2',v:'女'}];
        $scope.minzuType = [{k:'0',v:'汉族'},{k:'1',v:'蒙古族'},{k:'2',v:'回族'},{k:'3',v:'满族'},{k:'4',v:'维吾尔族'},{k:'5',v:'壮族'},{k:'6',v:'朝鲜族'}];
        $scope.zzmmType = [{k:'0',v:'未知'},{k:'1',v:'党员'},{k:'2',v:'预备党员'},{k:'3',v:'团员'},{k:'4',v:'群众'}];
        $scope.marryType = [{k:'0',v:'未婚'},{k:'1',v:'已婚'}];
        $scope.familyType = [{k:'0',v:'父亲'},{k:'1',v:'母亲'},{k:'2',v:'子女'}];
        $scope.empType = [{k:'0',v:'未知'},{k:'1',v:'临时合同聘用'},{k:'2',v:'劳务合同聘用'},{k:'3',v:'劳动合同聘用'}];
        $scope.xlType = [{k:'0',v:'未知'},{k:'1',v:'博士研究生'},{k:'2',v:'硕士研究生'},{k:'3',v:'本科'},{k:'4',v:'大专'},{k:'5',v:'中专及以下'}];
        $scope.offStatus = [{k: '0',v: ''},{k: '1',v: '正常'},{k: '2',v: '撤销'}];
        $scope.statusType = [{k:'0',v:'正常'},{k:'1',v:'产假'},{k:'2',v:'停薪留职'}];
        //嘉奖缘由
        $scope.jjcause = [{ k: '-1', v: '全部' }, { k: '0', v: '销售精英' }, { k: '1', v: '全勤奖' }, { k: '2', v: '月冠金奖' }];
        //嘉奖方式
        $scope.jjways = [{ k: '-1', v: '全部' }, { k: '0', v: '现金' }, { k: '1', v: '伙食补助' }, { k: '2', v: '房补' }];
        //惩罚缘由
        $scope.cfcause = [{ k: '-1', v: '全部' }, { k: '0', v: '迟到' }, { k: '1', v: '早退' }, { k: '2', v: '其他' }];
        //惩罚方式
        $scope.cfways = [{ k: '-1', v: '全部' }, { k: '0', v: '现金' }, { k: '1', v: '加班' },{ k: '2', v: '其他' }];
        $scope.findex = 'false';
        $scope.familys = [];
        $scope.family = '';
        $scope.eindex = 'false';
        $scope.edus = [];
        $scope.edu = '';
        $scope.tindex = 'false';
        $scope.trains = [];
        $scope.train = '';
        $scope.windex = 'false';
        $scope.works = [];
        $scope.work = '';
        $scope.pindex = 'false';
        $scope.pss = [];
        $scope.ps = '';
        $scope.hindex = 'false';
        $scope.hrcoms = [];
        $scope.hrcom = '';
        $scope.comms = [];
        $scope.punishs = [];
        $scope.ofs = [];


        // 家庭信息操作
        $scope.familyAdd = function(){
          setTimeout(function() { $('.ui.table.family .ui.dropdown').dropdown() }, 50);
          $('.ui.table.family').transition('fade down');
          $('.fr.family .ui.button').transition('toggle');
        }
        $scope.familySave = function(){
          if ($('.fam.ui.form').form('is valid')){
            $scope.findex != 'false' ? $scope.familys.splice($scope.findex, 1, $scope.family) : $scope.familys.push($scope.family);
            $scope.findex = 'false';
            $scope.family = '';
            $('#famFrom').form('clear');
            $('.ui.table.family').transition('fade down');
            $('.fr.family .ui.button').transition('toggle');
          }
        }
        $scope.familyCancel = function(){
          $scope.findex = 'false';
          $scope.family = '';
          $('#famFrom').form('clear');
          $('.ui.table.family').transition('fade down');
          $('.fr.family .ui.button').transition('toggle');
        }
        // 员工家庭修改
        $scope.familyEdit = function(){
          $scope.family = angular.copy(this.vfamily);
          $scope.findex = this.$index;
          setTimeout(function() { $('.ui.table.family .ui.dropdown').dropdown() }, 50);
          $('.ui.table.family').transition('fade down');
          $('.fr.family .ui.button').transition('toggle');
        }
        // 员工家庭信息删除
        $scope.familyDel = function(){
          $scope.findex = this.$index;
          $scope.familys.splice($scope.findex, 1);
          $scope.findex = 'false';
        }

        // 员工教育经历操作
        $scope.eduAdd = function(){
          setTimeout(function() { $('.ui.table.edu .ui.dropdown').dropdown() }, 50);
          $('.ui.table.edu').transition('fade down');
          $('.fr.edu .ui.button').transition('toggle');
        }
        $scope.eduSave = function(){
          if ($('.edu.ui.form').form('is valid')){
            $scope.eindex != 'false' ? $scope.edus.splice($scope.eindex, 1, $scope.edu) : $scope.edus.push($scope.edu);
            $scope.eindex = 'false';
            $scope.edu = '';
            $('#eduFrom').form('clear');
            $('.ui.table.edu').transition('fade down');
            $('.fr.edu .ui.button').transition('toggle');
          }
        }
        $scope.eduCancel = function(){
          $scope.eindex = 'false';
          $scope.edu = '';
          $('#eduFrom').form('clear');
          $('.ui.table.edu').transition('fade down');
          $('.fr.edu .ui.button').transition('toggle');
        }
        $scope.eduEdit = function(){
          $scope.edu = angular.copy(this.vedu);
          $scope.eindex = this.$index;
          setTimeout(function() { $('.ui.table.edu .ui.dropdown').dropdown() }, 50);
          $('.ui.table.edu').transition('fade down');
          $('.fr.edu .ui.button').transition('toggle');
        }
        $scope.eduDel = function(){
          $scope.eindex = this.$index;
          $scope.edus.splice($scope.eindex, 1);
          $scope.eindex = 'false';
        }

        // 员工培训经历操作
        $scope.trainAdd = function(){
          setTimeout(function() { $('.ui.table.train .ui.dropdown').dropdown() }, 50);
          $('.ui.table.train').transition('fade down');
          $('.fr.train .ui.button').transition('toggle');
        }
        $scope.trainSave = function(){
          if ($('.train.ui.form').form('is valid')){
            $scope.tindex != 'false' ? $scope.trains.splice($scope.tindex, 1, $scope.train) : $scope.trains.push($scope.train);
            $scope.tindex = 'false';
            $scope.train = '';
            $('#trainFrom').form('clear');
            $('.ui.table.train').transition('fade down');
            $('.fr.train .ui.button').transition('toggle');
          }
        }
        $scope.trainCancel = function(){
          $scope.tindex = 'false';
          $scope.train = '';
          $('#trainFrom').form('clear');
          $('.ui.table.train').transition('fade down');
          $('.fr.train .ui.button').transition('toggle');
        }
        $scope.trainEdit = function(){
          $scope.train = angular.copy(this.vtrain);
          $scope.tindex = this.$index;
          setTimeout(function() { $('.ui.table.train .ui.dropdown').dropdown() }, 50);
          $('.ui.table.train').transition('fade down');
          $('.fr.train .ui.button').transition('toggle');
        }
        $scope.trainDel = function(){
          $scope.tindex = this.$index;
          $scope.trains.splice($scope.tindex, 1);
          $scope.tindex = 'false';
        }


        // 员工工作经历操作
        $scope.workAdd = function(){
          setTimeout(function() { $('.ui.table.work .ui.dropdown').dropdown() }, 50);
          $('.ui.table.work').transition('fade down');
          $('.fr.work .ui.button').transition('toggle');
        }
        $scope.workSave = function(){
          if ($('.work.ui.form').form('is valid')){
            $scope.windex != 'false' ? $scope.works.splice($scope.windex, 1, $scope.work) : $scope.works.push($scope.work);
            $scope.windex = 'false';
            $scope.work = '';
            $('#workFrom').form('clear');
            $('.ui.table.work').transition('fade down');
            $('.fr.work .ui.button').transition('toggle');
          }
        }
        $scope.workCancel = function(){
          $scope.windex = 'false';
          $scope.work = '';
          $('#workFrom').form('clear');
          $('.ui.table.work').transition('fade down');
          $('.fr.work .ui.button').transition('toggle');
        }
        $scope.workEdit = function(){
          $scope.work = angular.copy(this.vwork);
          $scope.windex = this.$index;
          setTimeout(function() { $('.ui.table.work .ui.dropdown').dropdown() }, 50);
          $('.ui.table.work').transition('fade down');
          $('.fr.work .ui.button').transition('toggle');
        }
        $scope.workDel = function(){
          $scope.windex = this.$index;
          $scope.works.splice($scope.windex, 1);
          $scope.windex = 'false';
        }

        $scope.clickFriend = function (key){
          $scope.editEmpl.ext_isfriend = key;
        }
        $scope.clickBmcont = function (key){
          $scope.editEmpl.ext_isbmcont = key;
        }
        $scope.clickForBcont = function (key){
          $scope.editEmpl.ext_isforbcont = key;
        }
        $scope.clickSalary = function (key){
          $scope.editEmpl.ext_issalary = key;
        }

        // 员工岗位异动操作
        $scope.psAdd = function(){
            $timeout(function(){
                 $('.ui.table.ps .ui.dropdown.sector').dropdown('set selected');
            });
          // setTimeout(function() { $('.ui.table.ps .ui.dropdown.sector').dropdown('set selected') }, 50);
          $('.ui.table.ps').transition('fade down');
          $('.fr.ps .ui.button').transition('toggle');
        }
        $scope.psSave = function(){
          if ($('.ps.ui.form').form('is valid')){
            if($scope.pss.length < 1){
              $scope.ps['ps_old_sector'] = $scope.editUser['sector_id'];
              $scope.ps['old_sname'] = $scope.editUser['sector_name'];
              $scope.ps['ps_old_role'] = $scope.editUser['role_id'];
              $scope.ps['old_rname'] = $scope.editUser['role_name'];
            }else if($scope.pindex == 'false'){
              $scope.ps['ps_old_sector'] = $scope.pss[$scope.pss.length-1]['ps_new_sector'];
              $scope.ps['old_sname'] = $scope.pss[$scope.pss.length-1]['new_sname'];
              $scope.ps['ps_old_role'] = $scope.pss[$scope.pss.length-1]['ps_new_role'];
              $scope.ps['old_rname'] = $scope.pss[$scope.pss.length-1]['new_rname'];
            }
            $scope.ps['new_sname'] = $('.ui.table.ps .ui.dropdown.sector').dropdown('get text').replace(/—/g,"");
            $scope.ps['new_rname'] = $('.ui.table.ps .ui.dropdown.role').dropdown('get text').replace(/—/g,"");
            $scope.pindex != 'false' ? $scope.pss.splice($scope.pindex, 1, $scope.ps) : $scope.pss.push($scope.ps);
            if($scope.pindex != 'false'&& $scope.pindex < $scope.pss.length - 1){
              $scope.pss[$scope.pindex+1]['ps_old_sector'] = $scope.ps['ps_new_sector'];
              $scope.pss[$scope.pindex+1]['old_sname'] = $scope.ps['new_sname'];
              $scope.pss[$scope.pindex+1]['ps_old_role'] = $scope.ps['ps_new_role'];
              $scope.pss[$scope.pindex+1]['old_rname'] = $scope.ps['new_rname'];
            }
            $scope.pindex = 'false';
            $scope.ps = '';
            $('#psFrom').form('clear');
            $('.ui.table.ps').transition('fade down');
            $('.fr.ps .ui.button').transition('toggle');
          }
        }
        $scope.psCancel = function(){
          $scope.pindex = 'false';
          $scope.ps = '';
          $('#psFrom').form('clear');
          $('.ui.table.ps').transition('fade down');
          $('.fr.ps .ui.button').transition('toggle');
        }
        $scope.psEdit = function(){
          $scope.ps = angular.copy(this.vps);
          $scope.pindex = this.$index;
          setTimeout(function() { $('.ui.table.ps .ui.dropdown.sector').dropdown('set selected', $scope.ps.ps_new_sector) }, 50);
          setTimeout(function() { $('.ui.table.ps .ui.dropdown.role').dropdown('set selected', $scope.ps.ps_new_role) }, 50);
          $('.ui.table.ps').transition('fade down');
          $('.fr.ps .ui.button').transition('toggle');
        }
        $scope.psDel = function(){
          $scope.pindex = this.$index;
          $scope.pss.splice($scope.pindex, 1);
          $scope.pindex = 'false';
        }

        // 员工在司培训经历操作
        $scope.hrcomAdd = function(){
          setTimeout(function() { $('.ui.table.hrcom .ui.dropdown').dropdown() }, 50);
          $('.ui.table.hrcom').transition('fade down');
          $('.fr.hrcom .ui.button').transition('toggle');
        }
        $scope.hrcomSave = function(){
          if ($('.ps.ui.form').form('is valid')){
            $scope.hindex != 'false' ? $scope.hrcoms.splice($scope.hindex, 1, $scope.hrcom) : $scope.hrcoms.push($scope.hrcom);
            $scope.hindex = 'false';
            $scope.hrcom = '';
            $('#hrcomFrom').form('clear');
            $('.ui.table.hrcom').transition('fade down');
            $('.fr.hrcom .ui.button').transition('toggle');
          }
        }
        $scope.hrcomCancel = function(){
          $scope.hindex = 'false';
          $scope.hrcom = '';
          $('#hrcomFrom').form('clear');
          $('.ui.table.hrcom').transition('fade down');
          $('.fr.hrcom .ui.button').transition('toggle');
        }
        $scope.hrcomEdit = function(){
          $scope.hrcom = angular.copy(this.vhrcom);
          $scope.hindex = this.$index;
          setTimeout(function() { $('.ui.table.hrcom .ui.dropdown').dropdown() }, 50);
          $('.ui.table.hrcom').transition('fade down');
          $('.fr.hrcom .ui.button').transition('toggle');
        }
        $scope.hrcomDel = function(){
          $scope.hindex = this.$index;
          $scope.hrcoms.splice($scope.hindex, 1);
          $scope.hindex = 'false';
        }

    $('.menu .item').tab();
    $scope.editEmplModal = function( user_id ){
        function saveEdit() {
            dataFactoryCRM.postDataByAPI('employee/saveEdit',$scope.allData)
            .then(function(d){
              $scope.$emit('NOTBUSY');
              if(d.rcode){
                $scope.api_success(d.msg);
                $scope.getPageData();
                return true;
              }else{
                $scope.api_error(d.msg);
                return false;
              }
            });
        }

         dataFactoryCRM.getDataByAPI('employee/getEditInfo?user_id='+user_id)
            .then(function(d){
                if(d&&d.rcode){
                    $timeout(function() {
                        $scope.editUser = d.data['user'];
                        $scope.editEmpl = d.data['userExt'];
                        $scope.familys = d.data['family'];
                        $scope.edus = d.data['education'];
                        $scope.trains = d.data['train'];
                        $scope.works = d.data['workexp'];
                        $scope.pss = d.data['postExch'];
                        $scope.hrcoms = d.data['trainCom'];
                        $scope.editEmpl.ext_lastPer = $scope.lastUserId;
                        $scope.allData = {
                          user : $scope.editUser,
                          empl : $scope.editEmpl,
                          family : $scope.familys,
                          edu : $scope.edus,
                          train : $scope.trains,
                          work : $scope.works,
                          postExch : $scope.pss,
                          trainCom : $scope.hrcoms
                        };
                        $('.fir.ui.form .ui.selection.dropdown.sector').dropdown('set selected', $scope.editUser.sector_id);
                        $('.fir.ui.form .ui.selection.dropdown.role').dropdown('set selected', $scope.editUser.role_id);
                        setTimeout(function() { $('.fir.ui.form .ui.dropdown').dropdown() }, 50);
                        setTimeout(function() { $('.trd.ui.form .ui.dropdown').dropdown() }, 50);
                
                        $('.field .ui.radio.checkbox input').eq($scope.editEmpl.ext_isfriend).attr('checked',true);
                        $('.field.bmcont .ui.radio.checkbox input').eq($scope.editEmpl.ext_isbmcont).attr('checked',true);
                        $('.field.bcont .ui.radio.checkbox input').eq($scope.editEmpl.ext_isforbcont).attr('checked',true);
                        $('.field.salarr .ui.radio.checkbox input').eq($scope.editEmpl.ext_issalary).attr('checked',true);
                    });
                  $('.ui.edit').modal({
                    autofocus:false,
                    onApprove: function() {
                        if($('.fir.ui.form').form('is valid')) {
                            saveEdit();
                            return true;
                        }else
                            return false;
                    }
                  }).modal('setting', 'closable', false).modal('show');
                  // $('.second.modal').modal('attach events', '.first.modal .blue.button');
                  // $('ui.edit.large.modal').modal('show');
            }else{
              $scope.api_error('接口请求失败');
            }
        });
      
    }
    $scope.toggleCheckbox = function( ){

    }
    $scope.showEmplModal = function ( user_id ){
      dataFactoryCRM.getDataByAPI("employee/getShowInfo?user_id="+user_id).then(function(d){
        if(d&&d.rcode){
          $timeout(function(){
            $scope.editUser = d.data['user'];
            $scope.editEmpl = d.data['userExt'];
            $scope.familys = d.data['family'];
            $scope.edus = d.data['education'];
            $scope.trains = d.data['train'];
            $scope.works = d.data['workexp'];
            $scope.pss = d.data['postExch'];
            $scope.hrcoms = d.data['trainCom'];
            $scope.comms = d.data['commend'];
            $scope.punishs = d.data['punish'];
            $scope.ofs = d.data['offer'];
            // $scope.dimis = d.data['dimis'];
          });
          $('.ui.show').modal({
            autofocus:false,
            onApprove:function(){
              return true;
            }
          }).modal('setting', 'closable', false).modal('show');
        }else{
          $scope.api_error('接口请求失败');
        }
      });
    }

    window.loadClientCacheToScope($scope, function(){

    });

    }).directive('userStatus', function() {
            return {
                restrict: 'A',
                template: "{{status}}",
                link: function(scope, element, attrs) {
                    if (attrs.status) {
                        //员工状态: 离职员工、禁止登录、试用员工、正式员工
                        var code = parseInt( scope.$eval(attrs.status) );
                        code +=1;
                        code = 'A' + code;
                        var Names = {'A0':'离职员工','A1':'禁止登录','A2':'试用员工','A3':'正式员工'};
                        scope.status = Names[code];
                    }
                }
            };
        });
});
